package com.example.covid19.controller;


import cn.dev33.satoken.stp.StpUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.covid19.common.Dto.Editdto;
import com.example.covid19.common.lang.Result;
import com.example.covid19.entity.Stutoadmin;
import com.example.covid19.mapper.StutoadminMapper;
import com.example.covid19.service.StutoadminService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * <p>
 * VIEW 前端控制器
 * </p>
 *
 * @author BaiZhengChun
 * @since 2023-03-17
 */
@RestController
@RequestMapping("/stutoadmin")
public class StutoadminController {

    private final StutoadminMapper stutoadminMapper;
    private final StutoadminService stutoadminService;

    public StutoadminController(StutoadminMapper stutoadminMapper, StutoadminService stutoadminService) {
        this.stutoadminMapper = stutoadminMapper;
        this.stutoadminService = stutoadminService;
    }
    @RequestMapping("/getstuinfo")
    public Result getstuinfo(HttpServletRequest httpServletRequest){
        String token = (String) StpUtil.getLoginIdByToken(httpServletRequest.getHeader("satoken"));
       List<Stutoadmin> stutoadminList = stutoadminService.list(new QueryWrapper<Stutoadmin>().eq("studentid",token));
       if (stutoadminList==null){
           return Result.fail(400,"获取信息失败",null);
       }else {
           return Result.success(200,"获取成功",stutoadminList);
       }
    }
}
